require(['jquery', 'cookie', 'app', 'lay'], function ($) {
    require(['vue'], function (Vue) {
        var dictionary = new Vue({
            el: "#dictionary",
            data: {
                list: "",
                listCol:["员工编号","员工姓名","员工性别","联系方式"],
                dictionaryWHERE:"",
                num:""
            },
            created: function () {
                this.loadPage(0,10);
            },
            methods: {
                loadPage:function (begin,end) {
                    var jon={};
                    var sql="select personnelcode,personnelname,gender,ipone from personnel where 1=1";
                    if(this.dictionaryWHERE!=null&&this.dictionaryWHERE!=""){
                        for(var key in this.dictionaryWHERE){
                            sql+=" AND "+key+" like "+"'%"+this.dictionaryWHERE[key]+"%'";
                        }
                    }
                    sql+=" order by uuid limit "+begin+","+end;
                    jon['sql']=encodeURI(encodeURI(sql));
                    this.list=JSON.parse(playAjax("101",JSON.stringify(jon)))['data'];
                    this.num=JSON.parse(playAjax("101",JSON.stringify(jon)))['data'].length;
                },
                referXadmin: function () {
                    window.location.reload();
                },
            }
        });
        layui.use('form', function () {
            var form = layui.form;
            form.render();
            form.on('submit(soso)', function (data) {
                dictionary.dictionaryWHERE=data.field;
                dictionary.loadPage(0,10);
                return false;
            });
        });
        layui.use('laypage', function () {
            var laypage = layui.laypage;
            var jon = {};
            //执行一个laypage实例
            laypage.render({
                elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
                , count: dictionary.num//数据总数，从服务端得到
                , limit: 10
                , jump: function (obj, first) {
                    //obj包含了当前分页的所有参数，比如：
                    var x = obj.curr; //得到当前页，以便向服务端请求对应页的数据。
                    var y = obj.limit; //得到每页显示的条数
                    //首次不执行
                    if (!first) {
                        //do something
                        var begin = (x - 1) * y;
                        var end = y;
                        dictionary.loadPage(begin, end);
                    }
                }
            });
        });
    });
});